package me.fanchaoo.web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.fanchaoo.web.dto.MomentDTO;
import me.fanchaoo.web.dto.UserDTO;
import me.fanchaoo.web.dto.UserSettingDTO;
import me.fanchaoo.web.request.*;
import me.fanchaoo.web.response.BaseResponse;
import me.fanchaoo.web.service.MomentService;
import me.fanchaoo.web.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@Api(description = "用户")
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;
    @Autowired
    private MomentService momentService;
    @ApiOperation(value = "获取用户信息")
    @PostMapping(value = "/getUserInfo")
    public BaseResponse<UserDTO> getUserInfo(@Valid @RequestBody GetUserInfoRequest request) {
        return userService.getUserInfo(request);
    }

    @ApiOperation(value = "更新用户信息")
    @PostMapping(value = "/updateUserInfo")
    public BaseResponse updateUserInfo(@Valid @RequestBody UpdateUserInfoRequest request) {
        return userService.updateUserInfo(request);
    }


    @ApiOperation(value = "用户点赞动态")
    @PostMapping(value = "/queryUserLikeMoment")
    public BaseResponse<List<MomentDTO>> queryUserLikeMoment(@Valid @RequestBody UserLikeRequest request) {
        return momentService.queryUserLikeMoment(request);
    }

    @ApiOperation(value = "用户自己发布的动态")
    @PostMapping(value = "/queryUserOwnerMoment")
    public BaseResponse<List<MomentDTO>> queryUserOwnerMoment(@Valid @RequestBody PageRequest request) {
        return momentService.queryUserOwnerMoment(request);
    }


    @ApiOperation(value = "用户发布的动态")
    @PostMapping(value = "/queryOtherUserMoment")
    public BaseResponse<List<MomentDTO>> queryOtherUserMoment(@Valid @RequestBody OtherUserRequest request) {
        return momentService.queryOtherUserMoment(request);
    }


    @ApiOperation(value = "用户的设置")
    @PostMapping(value = "/queryUserSetting")
    public BaseResponse<UserSettingDTO> queryUserSetting(@Valid @RequestBody QueryOtherUserRequest request) {
        return userService.queryUserSetting(request);
    }

    @ApiOperation(value = "用户的设置")
    @PostMapping(value = "/updateUserSetting")
    public BaseResponse<UserSettingDTO> updateUserSetting(@Valid @RequestBody UpdateUserSettingRequest request) {
        return userService.updateUserSetting(request);
    }
    @ApiOperation(value = "用户搜索")
    @PostMapping(value = "/queryUsers")
    public BaseResponse<List<UserDTO>> queryUsers(@Valid @RequestBody QueryUsersRequest request) {
        return userService.queryUsers(request);
    }

}
